﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace HZ.Supervise.Web.Secondphase.ReportHospitalPurchase
{
    public partial class PrescriptionDoctor :BasePage
    {
        HZ.Supervise.IBLL.IBLL_Purchase ibllPurchase = HZ.Supervise.BLLFactory.IBLL_Purchase();
        public string ProcureCatalogID = "";
        public string PHospitalID = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            ProcureCatalogID = Request.QueryString["ProcureCatalogID"];
            PHospitalID = Request.QueryString["PHospitalID"];
           
            if (!IsPostBack)
            {
                setBind();
            }
        }
        public void setBind()
        {
            string where = "";
            where += "and GoodsID='" + ProcureCatalogID + "'";
            where += "and HospitalID='" + PHospitalID + "'";
            if (!string.IsNullOrEmpty(txtHospitalName.Text.Trim()))
            {
                where += "and DoctorName like'%" + txtHospitalName.Text.Trim() + "%' ";
            }
            where += "order by HospitalTotalCount desc";
            int totalCount = 0;
            DataTable dt = ibllPurchase.GetPdoctorNameByPHospitalId(where, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);
            gvwHospitalList.DataSource = dt;
            if (dt.Rows.Count > 0)
            {
                lblGoodsId.Text = dt.Rows[0]["GoodsID"].ToString();
                lblProductName.Text = dt.Rows[0]["ProductName"].ToString();
                lblCompanyName.Text = dt.Rows[0]["CompanyName_SC"].ToString();
                lblMedicineModel.Text = dt.Rows[0]["MedicineModelName"].ToString();
                lblOutLook.Text = dt.Rows[0]["Outlookc"].ToString();
                lblFactor.Text = dt.Rows[0]["Factor"].ToString();
                lblHospitalName.Text = dt.Rows[0]["HospitalName"].ToString();
                lblUnit.Text = dt.Rows[0]["Unit"].ToString();
                lblGoodsName.Text = dt.Rows[0]["GoodsName"].ToString();
            }
            else
            {
                lblGoodsId.Text = "暂无符合条件的数据";
                lblProductName.Text = "暂无符合条件的数据";
                lblCompanyName.Text = "暂无符合条件的数据";
                lblMedicineModel.Text = "暂无符合条件的数据";
                lblOutLook.Text = "暂无符合条件的数据";
                lblFactor.Text = "暂无符合条件的数据";
                lblUnit.Text = "暂无符合条件的数据";
                lblGoodsName.Text = "暂无符合条件的数据";
            }
            gvwHospitalList.DataBind();
            AspNetPager1.RecordCount = totalCount;
        }
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
        }
        /// <summary>
        /// 获取查询条件
        /// </summary>
        /// <returns></returns>
        private Model.Query.Prescription StoreQureyCondition()
        {
            Model.Query.Prescription Prescription = new Model.Query.Prescription();
            Prescription.ProcureCatalogID = ProcureCatalogID;
            Prescription.PHospitalId = PHospitalID;
            Prescription.SortFields = "HospitalTotalCount desc";
            return Prescription;
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            setBind();
        }

        protected void HzButton1_Click(object sender, EventArgs e)
        {
            Response.Redirect("PrescriptionHospital.aspx?ProcureCatalogID="+ProcureCatalogID);
        }
    }
}
